package cn.design;

import cn.design.realize.demo1.CleanState;
import cn.design.realize.demo1.Context;
import cn.design.realize.demo1.CustomerState;
import cn.design.realize.demo1.FreeState;

/**
 * @author dlq
 * @description
 *    状态模式客户端类：
 * @date 2020/10/12 9:14
 * @since 1.0
 */
public class StateClientDemo1 {
    public static void main(String[] args) {

        //酒店房间的状态
        //你现在是酒店经理,你要根据房间的状态来进行打扫卫生
        // 房间有三个状态
        // 空闲状态 , 客户住进状态 , 打扫状态(假设打扫转态是不可以客户住进的)

        //客户住进房间
        Context context = new Context(new CustomerState());
        context.execute("客户住进房间了.....");
        //客户退房,打扫房间
        context.setState(new CleanState());
        context.execute("客户退房,清洁员去打扫房间");

        //打扫完房间,房间处于空闲状态
        context.setState(new FreeState());
        context.execute("房间打扫完毕");
    }
}
